package com.wechat.scheme.service.impl;

import com.wechat.scheme.entity.WxButton;
import com.wechat.scheme.entity.model.WxButtonMo;
import com.wechat.scheme.repo.WxButtonRepo;
import com.wechat.scheme.repo.mapper.WxbutMapper;
import com.wechat.scheme.service.WxButtonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class WxButtonServiceImpl implements WxButtonService {
    @Autowired
    WxButtonRepo buttonRepo;
    @Override
    public void saveBt(WxButtonMo wxButton) {
        WxButton button = WxbutMapper.INSTANCE.DTOToEntity(wxButton);
        buttonRepo.save(button);
    }

    @Override
    public void delBt(String id) {
        buttonRepo.deleteById(id);
    }

    @Override
    public List<WxButton> findBt(String appId) {
        List<WxButton> buttonList = buttonRepo.findBySourceAppId(appId);
        return buttonList;
    }
}
